# -*- coding: utf-8 -*-
'''
942. 增减字符串匹配
'''


class Solution:

    def diStringMatch(self, s):
        resList = []
        if len(s) == 0:
            return []

        minNum, maxNum = 0, len(s)
        for c in s:
            if c=='I':
                resList.append(minNum)
                minNum+=1
            else:
                resList.append(maxNum)
                maxNum-=1

        resList.append(minNum)
        return resList


print(Solution().diStringMatch("DDI"))